﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.XCMG.Util;

namespace PMS.XCMG.Entity
{
    /// <summary>
    /// Sys_Personnel
    /// </summary>
    public partial class Sys_Personnel : BusEntity
    {
        /// <summary>
        /// 编码
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 照片
        /// </summary>
        public string Photo { set; get; }
        /// <summary>
        /// 所属部门Id
        /// </summary>
        public string OrgId { get; set; }
        /// <summary>
        /// 岗位/角色名称
        /// </summary>
        public string RoleName { get; set; }
        /// <summary>
        /// 性别
        /// </summary>
        public string Sex { get; set; }
        /// <summary>
        /// 证件号
        /// </summary>
        public string Card { get; set; }
        /// <summary>
        /// 电话
        /// </summary>
        public string Phone { get; set; }
        /// <summary>
        /// 地址
        /// </summary>
        public string Addr { get; set; }
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class Sys_PersonnelTypeConfig : BusEntityTypeConfig<Sys_Personnel>, IEntityTypeConfiguration<Sys_Personnel>
    {
        public override void Configure(EntityTypeBuilder<Sys_Personnel> builder)
        {
            base.Configure(builder);

            #region 主外键关系
            //builder.HasOne(o => o.Whse).WithMany().HasForeignKey(p => p.WhseId).OnDelete(DeleteBehavior.ClientCascade);
          //  builder.HasOne(o => o.Storer).WithMany().HasForeignKey(p => p.StorerId).OnDelete(DeleteBehavior.ClientCascade);
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.Code).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.Name).HasMaxLength(EntityDefinition.DefMiddleColLen).IsRequired();
            builder.Property(p => p.OrgId).HasMaxLength(EntityDefinition.DefSmallColLen);
            builder.Property(p => p.RoleName).HasMaxLength(EntityDefinition.DefSmallColLen);
            builder.Property(p => p.Sex).HasMaxLength(EntityDefinition.DefSmallColLen);
            builder.Property(p => p.Card).HasMaxLength(EntityDefinition.DefSmallColLen);
            builder.Property(p => p.Phone).HasMaxLength(EntityDefinition.DefSmallColLen);
            builder.Property(p => p.Addr).HasMaxLength(EntityDefinition.DefLargeColLen);
            #endregion

            #region 备注
            builder.HasComment("Sys_Personnel");
            builder.Property(p => p.Code).HasComment("编码");
            builder.Property(p => p.Name).HasComment("姓名");
            builder.Property(p => p.OrgId).HasComment("所属部门Id");
            builder.Property(p => p.RoleName).HasComment("岗位/角色名称");
            builder.Property(p => p.Sex).HasComment("性别");
            builder.Property(p => p.Card).HasComment("证件号");
            builder.Property(p => p.Phone).HasComment("电话");
            builder.Property(p => p.Addr).HasComment("地址");
            #endregion

            #region 种子数据
            #endregion
        }
    }
}
